﻿using ConfExpert.Forms.Base;
using ConfExpert.Utility;
using DevExpress.XtraEditors.Repository;
using Extensions;
using System;
using System.Data;
using System.Windows.Forms;



namespace ConfExpert.Forms.IT
{
    public partial class EnvanterBilgiGir : XPopupForm
    {

        public EnvanterBilgiGir()
        {
            InitializeComponent();
        }

        private DevExpress.XtraGrid.Views.Grid.GridView gridView2;
        private void EnvanterBilgiGir_Load(object sender, EventArgs e)
        {
            gleSirket.Properties.Assign(RI(Rp.Sirket));

            RepositoryItemGridLookUpEdit riEL;
            DataTable dtEL = ExecuteDataTable("GetEnvanterLokasyon");
            riEL = RepositoryManager.GetGLESablon(dtEL, "Name", "IT_LokasyonId");
            gleLokasyon.Properties.Assign(riEL);
       
            RepositoryItemGridLookUpEdit riEA;
            DataTable dtEA = ExecuteDataTable("GetEnvanterAlan");
            riEA = RepositoryManager.GetGLESablon(dtEA, "Name", "IT_AlanId");
            gleAlan.Properties.Assign(riEA);

            RepositoryItemGridLookUpEdit riEC;
            DataTable dtEC = ExecuteDataTable("GetEnvanterCesit");
            riEC = RepositoryManager.GetGLESablon(dtEC, "Name", "IT_EnvanterCesitId");
            gleEnvanterCesit.Properties.Assign(riEC);
       
            btnKaydet.ItemClick += btnKaydet_ItemClick;
            this.Shown += EnvanterBilgiGir_Shown;

        }

       
        void EnvanterBilgiGir_Shown(object sender, EventArgs e)
        {
            txtUrunAdi.Focus();
        }

        void btnKaydet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            TAM.IT_EnvanterTableAdapter = new ITaskManager.Datasets.MyDataTableAdapters.IT_EnvanterTableAdapter();
            ITaskManager.Datasets.MyData.IT_EnvanterRow er = ds.IT_Envanter.NewIT_EnvanterRow();
            er.UrunAdi = txtUrunAdi.Text;
            er.SirketId = gleSirket.EditValue.ToInt();
            er.IT_AlanId = gleAlan.EditValue.ToInt();
            er.IT_LokasyonId = gleLokasyon.EditValue.ToInt();
            er.UserId = WhoAmI;
            er.IsletimSistemi = txtIsletimSis.Text;
            er.BilgisayarMarka = txtBilMarka.Text;
            er.Model = txtModel.Text;
            er.Islemci = txtIslemci.Text;
            er.GHz = txtGHz.Text;
            er.RAM = txtRAM.Text;
            er.HDD = txtHDD.Text;
            er.Yazici = txtYazici.Text;
            er.AntiVirüs = txtAntiVirus.Text;
            er.RDP = txtRDP.Text;
            er.Hostname = txtHostname.Text;
            er.EthIPAdresi = txtEthAdresi.Text;
            er.EthMacAdresi = txtEthMacAdresi.Text;
            er.WLANIPAdresi = txtWAdresi.Text;
            er.WLANMACAdresi = txtWMAdresi.Text;
            er.OfisUyg1 = txtUyg1.Text;
            er.OfisUyg2 = txtUyg2.Text;
            er.OtherUyg = txtOtherUyg.Text;
            er.OfficeKey = txtOfficeKey.Text;
            er.WindowsKey = txtWinKey.Text;
            er.Aciklama = meAciklama.Text;
            er.GarantiBasTarihi = deBasTarihi.EditValue.ToDate();
            er.GarantiBitTarihi = deBitTarihi.EditValue.ToDate();
            er.SeriNo = txtSeriNo.Text;
            er.IMEI = txtIMEI.Text;
            ds.IT_Envanter.AddIT_EnvanterRow(er);
            TAM.IT_EnvanterTableAdapter.Update(ds.IT_Envanter);
            //AppSession.MainForm.ShowMdiChildForm(typeof(EnvanterEkle),er.IT_EnvanterId);
            this.DialogResult = DialogResult.OK;

            //string str = gridView2.SerializeChanges();
            //ExecuteNonQuery("IT_UpdEnvanterKodu",str);
            //gridView2.VeriyiGuncelle("IT_GetFatura", Session.SirketId);

        }

    }
}
